<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/include/commonHeader::commonHeader('人员冲突编辑')"></head>
<body>
<div class="wrapper wrapper-content">
    <div class="col-sm-12">
        <form class="form-horizontal m-t" id="exampleForm">
            <input id="serialNoOld" name="serialNoOld"  type="hidden" th:value="${authorizedStrength.serialNoOld}">
            <div class="form-group">
                <label class="col-xs-3 control-label">机组编制：</label>
                <div class="col-xs-8">
                    <select id="crewId" name="crewId"　class="form-control" th:value="${authorizedStrength.crewId}" disabled></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">号位：</label>
                <div class="col-sm-8">
                    <input id="serialNo" name="serialNo" th:value="${authorizedStrength.serialNo}" class="form-control" type="text" disabled>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">机上岗位：</label>
                <div class="col-xs-8">
                    <select id="rankNo" name="rankNo"　class="form-control" th:value="${authorizedStrength.rankNo}"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-3 control-label">排班授权：</label>
                <div class="col-xs-8">
                    <select id="techNos" name="techNos"　class="form-control" th:value="${authorizedStrength.techNos}" multiple></select>
                </div>
            </div>

            <div class="form-group">
                <div class="text-center">
                    <button id="btn_save" onclick="save()" type="button" class="btn btn-primary">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/plugins/bootstrapValidator/js/bootstrapValidator.min.js"></script>
<script src="/plugins/bootstrapValidator/js/language/zh_CN.js"></script>
<!-- 自定义js -->
<script th:inline="javascript">
    var prefix = "/authorizedStrength";
    var isReadonly = "[[${isReadonly}]]";//页面是否只能查看
    var moduleFlag = "[[${moduleFlag}]]".substr(1,1);

    $(function () {
        //初始化下列框
        //select2InitForData("#techNos", "/select2/getTechNoZ.do?techType="+moduleFlag,null, null, false, null);     //排班授权T3021---多选
        select2InitForData("#crewId", "/select2/getCrewNumberType.do?moduleFlag="+moduleFlag,[[${authorizedStrength.crewId}]], null, false, null);      //组搭配标准C3026
        select2InitForData("#rankNo", "/select2/getFlightPosition.do?rankFlag="+moduleFlag, [[${authorizedStrength.rankNo}]], null, false, null);        //机上岗位T3020
    });

    var techNos = "[[${authorizedStrength.techNos}]]";
    var techNoArr = [];
    if(techNos != ""){
        techNos = techNos.substr(1,techNos.length-2);
        techNoArr = techNos.split("/");
        select2InitForData("#techNos", "/select2/getTechNoZ.do?techType="+moduleFlag,techNoArr, null, false, null);     //排班授权T3021---多选
    }
    //保存
    function save() {
        techNoArr = $("#techNos").val();
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + "/save.do",
            data: {
                crewId : $("#crewId").val(),
                serialNo : $("#serialNo").val(),
                serialNoOld : $("#serialNoOld").val(),
                rankNo : $("#rankNo").val(),
                techNoArr : techNoArr,
                moduleFlag : moduleFlag,
            },
            error : function(request) {
                toastr.error("保存失败");
            },
            success : function(data) {
                if (data.code == 0) {
                    parent.toastr.success("操作成功");
                    parent.reload();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);
                } else {
                    toastr.warning(data.msg)
                }
            }
        });
    }



</script>
</body>
</html>
